package com.crm.business.crm.controller;


import com.crm.business.crm.service.ICrmRoiPutinService;
import com.crm.common.annotation.RepeatSubmit;
import com.crm.common.crm.entity.BO.CrmRoiPutinPageBO;
import com.crm.common.crm.entity.PO.CrmRoiPutin;
import com.crm.common.ka.core.common.R;
import com.crm.common.ka.core.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 投放消耗表 前端控制器
 * </p>
 *
 * @author zhangzhiwei
 * @since 2020-05-21
 */
@RestController
@RequestMapping("/crmRoiPutin")
@Api(tags = "投放模块接口")
public class CrmRoiPutinController {

    @Autowired
    private ICrmRoiPutinService crmRoiPutinService;

    @PostMapping("/queryPageList")
    @ApiOperation("查询列表页数据")
    public Result queryPageList(@RequestBody CrmRoiPutinPageBO roiPutinPageBO){
        return R.ok(crmRoiPutinService.queryPageList(roiPutinPageBO));
    }

    @PostMapping("/add")
    @RepeatSubmit
    public Result add(@RequestBody CrmRoiPutin crmRoiPutin){
        crmRoiPutinService.addOrUpdate(crmRoiPutin);
        return R.ok();
    }

    @PostMapping("/update")
    @RepeatSubmit
    public Result update(@RequestBody CrmRoiPutin crmRoiPutin){
        crmRoiPutinService.addOrUpdate(crmRoiPutin);
        return R.ok();
    }

    /**
     * 查看明细
     * @param putinId 主键Id
     * @return
     */
    @GetMapping("/getRoiDataById")
    public Result getRoiDataById(@RequestParam("putinId") Integer putinId){
        return R.ok(crmRoiPutinService.getRoiDataById(putinId));
    }

}
